<template>
  <div class="start">
    <div class="box">
      <image
        class="background"
        mode="aspectFill"
        src="../../static/img/background.jpg"
      ></image>
    </div>
  </div>
</template>
<script lang="ts">
import { wechatLogin } from "@/api/auth";
import Vue from "vue";
export default Vue.extend({
  onLoad(ops: any) {
    console.log(ops);
    if (ops.scene) {
      let params = decodeURIComponent(ops.scene);
      console.log(params);
      let userId = params.split("=")[1];
      console.log(userId);
      this.$store.commit("user/setInvitorId", userId);
    }
    this.$store.dispatch("setting/getSetting");
    uni.checkSession({
      success: (res) => {
        let token = uni.getStorageSync("token");
        if (!token) {
          wechatLogin();
        } else {
          setTimeout(() => {
            uni.reLaunch({
              url: "/pages/index/index",
            });
          }, 1500);
        }
      },
      fail: (res) => {
        wechatLogin();
      },
    });
  },
});
</script>
<style scoped lang="scss">
.start {
  width: 100%;
  height: 100vh;
  // position: relative;

  .box {
    width: 100%;
    height: 100vh;

    .background {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
